<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class About extends Admin_Controller {
	
	private $legalityId 	= PAGE_LEGALITY_ID;
	private $philosophyId 	= PAGE_PHILOSOPHY_ID;
	private $associationId 	= PAGE_ASSOCIATION_ID;
	private $mgProfileId 	= PAGE_MG_PROFILE_ID;
	
    function __construct() {
        parent::__construct();
    }

	public function index(){
		$this->legality();
	}
	
	public function legality(){
		$data['data'] = $this->mod_page->getPageById($this->legalityId);
		
		$data['title']	= 'Company Legality';
		$data['page']	= 'page/about/legality/view';
		$data['action']	= 'Company Legality';
		$this->load->view('layout/admin',$data);
	}
	
	public function edit_legality(){
		if($this->input->post('btnSave')){
        	$this->form_validation->set_rules('description', 'Description', 'trim|required');
			
        	if ($this->form_validation->run() == TRUE) {
				$description = $this->input->post('description');
				
				if($this->mod_page->update($this->legalityId, $description)){
					$this->session->set_userdata('ms', 'Successfully changed!');
				} else {
					$this->session->set_userdata('ms', 'Could not updated, please try again!');
				}
				redirect('page/about/legality');
			}
		}
		$data['data'] = $this->mod_page->getPageById($this->legalityId);
		
		$data['title']	= 'Edit Company Legality';
		$data['page']	= 'page/about/legality/edit';
		$data['action']	= 'Edit Company Legality';
    	$this->load->view('layout/admin',$data);
	}
	
	public function philosophy(){
		$data['data'] = $this->mod_page->getPageById($this->philosophyId);
		
		$data['title']	= 'Our Company Philosophies';
		$data['page']	= 'page/about/philosophy/view';
		$data['action']	= 'Our Company Philosophies';
		$this->load->view('layout/admin',$data);
	}
	
	public function edit_philosophy(){
		if($this->input->post('btnSave')){
        	$this->form_validation->set_rules('description', 'Description', 'trim|required');
			
        	if ($this->form_validation->run() == TRUE) {
				$description = $this->input->post('description');
				
				if($this->mod_page->update($this->philosophyId, $description)){
					$this->session->set_userdata('ms', 'Successfully changed!');
				} else {
					$this->session->set_userdata('ms', 'Could not updated, please try again!');
				}
				redirect('page/about/philosophy');
			}
		}
		$data['data'] = $this->mod_page->getPageById($this->philosophyId);
		
		$data['title']	= 'Edit Our Company Philosophies';
		$data['page']	= 'page/about/philosophy/edit';
		$data['action']	= 'Edit Our Company Philosophies';
    	$this->load->view('layout/admin',$data);
	}
	
	public function association(){
		$data['data'] = $this->mod_page->getPageById($this->associationId);
		
		$data['title']	= 'Our Association Mill House';
		$data['page']	= 'page/about/association/view';
		$data['action']	= 'Our Association Mill House';
		$this->load->view('layout/admin',$data);
	}
	
	public function edit_association(){
		if($this->input->post('btnSave')){
        	$this->form_validation->set_rules('description', 'Description', 'trim|required');
			
        	if ($this->form_validation->run() == TRUE) {
				$description = $this->input->post('description');
				
				if($this->mod_page->update($this->associationId, $description)){
					$this->session->set_userdata('ms', 'Successfully changed!');
				} else {
					$this->session->set_userdata('ms', 'Could not updated, please try again!');
				}
				redirect('page/about/association');
			}
		}
		$data['data'] = $this->mod_page->getPageById($this->associationId);
		
		$data['title']	= 'Edit Our Association Mill House';
		$data['page']	= 'page/about/association/edit';
		$data['action']	= 'Edit Our Association Mill House';
    	$this->load->view('layout/admin',$data);
	}
	
	public function management_profile(){
		$data['data'] = $this->mod_page->getPageById($this->mgProfileId);
		
		$data['title']	= 'Management Profile';
		$data['page']	= 'page/about/management_profile/view';
		$data['action']	= 'Management Profile';
		$this->load->view('layout/admin',$data);
	}
	
	public function edit_management_profile(){
		if($this->input->post('btnSave')){
        	$this->form_validation->set_rules('description', 'Description', 'trim|required');
			
        	if ($this->form_validation->run() == TRUE) {
				$description = $this->input->post('description');
				
				if($this->mod_page->update($this->mgProfileId, $description)){
					$this->session->set_userdata('ms', 'Successfully changed!');
				} else {
					$this->session->set_userdata('ms', 'Could not updated, please try again!');
				}
				redirect('page/about/management_profile');
			}
		}
		$data['data'] = $this->mod_page->getPageById($this->mgProfileId);
		
		$data['title']	= 'Edit Management Profile';
		$data['page']	= 'page/about/management_profile/edit';
		$data['action']	= 'Edit Management Profile';
    	$this->load->view('layout/admin',$data);
	}
}
